In Fortran, _p_S_y_n_c must be of type integer and size
SSSSHHHHMMMMEEEEMMMM____RRRREEEEDDDDUUUUCCCCEEEE____SSSSYYYYNNNNCCCC____SSSSIIIIZZZZEEEE. If you are using Fortran, it
must be a default integer value.
Every element of this array must be initialized with the
value ____SSSSHHHHMMMMEEEEMMMM____SSSSYYYYNNNNCCCC____VVVVAAAALLLLUUUUEEEE (in C/C++) or SSSSHHHHMMMMEEEEMMMM____SSSSYYYYNNNNCCCC____VVVVAAAALLLLUUUUEEEE
(in Fortran) before any of the PEs in the active set
enter the reduction routine.
The values of arguments _n_r_e_d_u_c_e, _P_E__s_t_a_r_t, _l_o_g_P_E__s_t_r_i_d_e, and _P_E__s_i_z_e
must be equal on all PEs in the active set. The same _t_a_r_g_e_t and
_s_o_u_r_c_e arrays, and the same _p_W_r_k and _p_S_y_n_c work arrays, must be passed
to all PEs in the active set.
Before any PE calls a reduction routine, you must ensure that the
following conditions exist (synchronization via a barrier or some
other method is often needed to ensure this):
* The _p_W_r_k and _p_S_y_n_c arrays on all PEs in the active set are not still
in use from a prior call to a collective SHMEM routine.
* The _t_a_r_g_e_t array on all PEs in the active set is ready to accept the
results of the reduction.
Upon return from a reduction routine, the following are true for the
local PE:
* The _t_a_r_g_e_t array is updated.
* The data cache region mapped to _t_a_r_g_e_t is coherent.
* The values in the _p_S_y_n_c array are restored to the original values.
NNNNOOOOTTTTEEEESSSS
The terms _c_o_l_l_e_c_t_i_v_e, _s_y_m_m_e_t_r_i_c, and _c_a_c_h_e _a_l_i_g_n_e_d are defined in
iiiinnnnttttrrrroooo____sssshhhhmmmmeeeemmmm(3).
All SHMEM reduction routines reset the values in _p_S_y_n_c before they
return, so a particular _p_S_y_n_c buffer need only be initialized the
first time it is used.
You must ensure that the _p_S_y_n_c array is not being updated on any PE in
the active set while any of the PEs participate in processing of a
SHMEM reduction routine. Be careful to avoid the following
situations:
* If the _p_S_y_n_c array is initialized at run time, some type of
synchronization is needed to ensure that all PEs in the working set
have initialized _p_S_y_n_c before any of them enter a SHMEM routine
called with the _p_S_y_n_c synchronization array.
* A _p_S_y_n_c or _p_W_r_k array can be reused in a subsequent reduction
routine call only if none of the PEs in the active set are still
processing a prior reduction routine call that used the same _p_S_y_n_c
or _p_W_r_k arrays. In general, this can be assured only by doing some
type of synchronization. However, in the special case of reduction
routines being called with the same active set, you can allocate two
_p_S_y_n_c and _p_W_r_k arrays and alternate between them on successive
calls.
EEEEXXXXAAAAMMMMPPPPLLLLEEEESSSS
Example 1: This Fortran example statically initializes the _p_S_y_n_c
array and finds the logical AND of the integer variable FFFFOOOOOOOO across all
even PEs.
INCLUDE "mpp/shmem.fh"
INTEGER PSYNC(SHMEM_REDUCE_SYNC_SIZE)
DATA PSYNC /SHMEM_REDUCE_SYNC_SIZE*SHMEM_SYNC_VALUE/
PARAMETER (NR=1)
REAL PWRK(MAX(NR/2+1,SHMEM_REDUCE_MIN_WRKDATA_SIZE))